<?php
set_time_limit(0);
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
$dbhost = 'localhost';
$dbuser = 'root';
$dbpwd  ='song';
$dbName ='gu';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);

$dbhost = '47.110.131.55';
$dbuser = 'root';
$dbpwd  ='sxy7788123456';
$dbName ='gu';
$mysqliBig = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);


$query=$mysqli->query("SELECT * FROM `da` WHERE `miao` = 0 limit 0,100   ");

 
while ($list=$query->fetch_assoc()){
    $id=$list['id'];
    $time=$list['createtime'];
    $openid=$list['openid'];
    $nianji=$list['nianji'];
    $timeA=strtotime($time);
    
    echo $id,'....',$time,'....',$openid,'....',$nianji;
    echo "<br /><br />";
    echo $timeA;
    echo "<br /><br />";
    $sql="SELECT createtime FROM da_log".$nianji." where openid='".$openid."' limit 0,1 ";
   echo $sql;
   echo "<br /><br />";
    $queryU=$mysqliBig->query($sql);
    if($queryU->num_rows>0){
        $getData=$queryU->fetch_assoc();
        var_dump($getData);
        $timeB=strtotime($getData['createtime']);
        
        echo $timeB;
        echo "<br /><br />";
        
        $cha=$timeA - $timeB;
        echo $cha;
     
        echo "<br /><br />";
        
        if ($cha < 0){
            $cha=rand(10,200);
        }
    
    }else{
        $cha=rand(10,200);
    }
    
    $m = floor(($cha%(3600*24))%3600/60);
    $s = floor(($cha%(3600*24))%60);
    echo $m,'....',$s;
    echo "<br /><br />";
    $miao=$m*60 + $s;
    if ($miao > 600){
        $miao=rand(550,600);
    }
    echo "<br /><br />";
    
    $sql="update da set miao=".$miao." where id='".$list['id']."' ";
    echo $sql;
    echo "<br /><br />";
    
    $mysqli->query($sql);
    
    
}
?>
<script> 
window.setTimeout(function(){
	window.location.reload(); 
}, 1400);
</script>
 
